/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.bff.slimserver.musicjukebox.ui.components;

import com.bff.slimserver.music.exceptions.PlaylistException;
import com.bff.slimserver.musicjukebox.lib.JukeboxProperties;
import com.bff.slimserver.musicjukebox.lib.events.PlayerChosenEvent;
import com.bff.slimserver.musicjukebox.lib.events.PlayerChosenListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JButton;
import org.bff.slimserver.SlimPlayer;
import org.bff.slimserver.SlimPlaylist;

/**
 *
 * @author bfindeisen
 */
public abstract class PlayerButton
        extends JButton
        implements MouseListener {

    private SlimPlayer player;
    private SlimPlaylist playlist;

    public PlayerButton() {
        setPlayer(JukeboxProperties.getInstance().getPlayer());
        try {
            setPlaylist(JukeboxProperties.getInstance().getPlaylist());
        } catch (PlaylistException ex) {
            Logger.getLogger(PlayerButton.class.getName()).log(Level.SEVERE, null, ex);
        }
        setAction();

        addMouseListener(this);
    }

    /**
     * @return the player
     */
    public SlimPlayer getPlayer() {
        return player;
    }

    /**
     * @param player the player to set
     */
    public void setPlayer(SlimPlayer player) {
        this.player = player;
    }

    @Override
    public void mouseClicked(MouseEvent e) {
        //throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void mousePressed(MouseEvent e) {
        setMousePressedIcon();
    }

    @Override
    public void mouseReleased(MouseEvent e) {
       setMouseReleasedIcon();
    }

    @Override
    public void mouseEntered(MouseEvent e) {
        setMouseEnteredIcon();
    }

    @Override
    public void mouseExited(MouseEvent e) {
        setMouseExitedIcon();
    }

    protected abstract void setMousePressedIcon();

    protected abstract void setMouseEnteredIcon();

    protected abstract void setMouseExitedIcon();

    protected abstract void setAction();

    protected abstract void setMouseReleasedIcon();

    /**
     * @return the playlist
     */
    public SlimPlaylist getPlaylist() {
        return playlist;
    }

    /**
     * @param playlist the playlist to set
     */
    public void setPlaylist(SlimPlaylist playlist) {
        this.playlist = playlist;
    }
}
